<template>
  <div>
    <!--弹框展示联系电话-->
    <ShareSheet
      v-model="showVailble"
      title="联系我们"
      :options="options"
      @select="onSelectShare"
    />
  </div>
</template>

<script>
import { ShareSheet, Toast } from 'vant'
export default {
  name: 'MobileConnectUs',
  components: {
    ShareSheet
  },
  data () {
    return {
      options: [
        [
          {
            name: '拨打手机1',
            icon: 'http://backmanage.yuxjt.com//uploads/20200705/f565727fdbffbc1d04359f29b7fbdb15.png',
            description: '13883275906' },
          {
            name: '拨打手机2',
            icon: 'http://backmanage.yuxjt.com//uploads/20200705/382f9017f0dbf3ebf99598dbbda81379.png',
            description: '18623079633' },
          {
            name: '拨打座机',
            icon: 'http://backmanage.yuxjt.com//uploads/20200705/32e6db614db6ca4998921cfde138af83.png',
            description: '02368536157'}
        ],
        [
          { name: '复制链接', icon: 'link' },
          { name: '复制微信', icon: 'wechat' },
          { name: '复制QQ', icon: 'qq' }
        ]
      ],
      showVailble: this.iphoneNumShow
    }
  },
  props: {
    iphoneNumShow: {
      type: Boolean,
      default: true
    }
  },
  watch: {
    iphoneNumShow (val) {
      this.showVailble = val
    },
    showVailble (val) {
      this.$emit('update:iphoneNumShow', val)
    }
  },
  methods: {
    onSelectShare (option) {
      const { name, description } = option

      if (name === '拨打手机1' || name === '拨打手机2' || name === '拨打座机') {
        window.location.href = 'tel:' + description
      }

      if (name === '复制微信') {
        this.$copyText('LSG5158').then(function (e) {
          Toast('复制微信成功')
        }, function (e) {
          Toast('复制失败')
        })
      }

      if (name === '复制QQ') {
        this.$copyText('332593967').then(function (e) {
          Toast('复制QQ成功')
        }, function (e) {
          Toast('复制失败')
        })
      }

      if (name === '复制链接') {
        this.$copyText('http://www.yuxjt.com').then(function (e) {
          Toast('复制链接成功')
        }, function (e) {
          Toast('复制失败')
        })
      }
    }
  }
}
</script>

<style scoped>

</style>
